<extend name="Index:base" />
        <block name="b_content">
            <div id="content-header">
                <h1>统计</h1>
            </div>
            <div id="breadcrumb">
                <a href="{:U('/')}" title="Go to Home" class="tip-bottom"><i class="icon-home"></i> Home</a>
                <a href="#" class="current">统计</a>
            </div>
            <div class="container-fluid">
                <div class="row-fluid">
                    <div class="btn-group" role="group">
                        <a href="javascript:;" class="btn btn-default <eq name="ltype" value="1">btn-chosen</eq>">注册用户统计</a>
                    </div>
                    <div class="btn-group" role="group">
                        <form action="{:U('/Prom/Index/stat@'. getDomain())}" method="post" >
                            <input type="hidden" id="begin" name="begin" value="{$begin}" />
                            <input type="hidden" id="end" name="end" value="{$end}" />
                            <label>开始日期：<input id="begins" type="text" value="" placeholder="日期格式 2016-02-13" /></label>&nbsp;
                            <label>结束日期：<input id="ends"  type="text" value="" placeholder="日期格式 2016-02-13" /></label>
                            <button type="submit" class="btn btn-default"><i class="icon-search"></i>查询</button>
                            <input type="hidden" name="ltype" value="{$ltype}" />
                        </form>
                    </div>
                </div>
                <div class="row-fluid">
                    <div class="span12">
                        <div class="widget-box">
                            <div class="widget-title">
                                <span class="icon">
                                    <input type="checkbox" id="title-checkbox" name="title-checkbox" />
                                </span>
                                <h5>新注册用户列表</h5>
                            </div>
                            <div class="widget-content nopadding">
                                <table class="table table-bordered table-striped with-check">
                                    <thead>
                                        <tr>
                                            <th><i class="icon-resize-vertical"></i></th>
                                            <th>uid</th>
                                            <th>账号</th>
                                            <th>用户类型</th>
                                            <th>昵称</th>
                                            <th>性别</th>
                                            <th>注册时间</th>
                                            <th>操作</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                    <volist name="list" id="item" >
                                        <tr <if condition="$item['emailverify'] eq 0">style="color:#f00;"</if> >
                                            <td><input type="checkbox" /></td>
                                            <td>{$item.uid} <if condition="$item['emailverify'] eq 0">(未激活)</if> </td>
                                            <td>{$item.email}</td>
                                            <td><if condition="$item.utype eq 2">企业用户<elseif condition="$item.utype eq 1"/>个人用户</if></td>
                                            <td><a href="{:U('/Prom/Index/userinfo@'. getDomain(), array('uid'=>$item['uid']))}" target="blank">{$item.nickname}</a></td>
                                            <td>{$item.gender|toGender}</td>
                                            <td>{$item.ctime|toTime}</td>
                                            <td>
                                                <neq name="ltype" value="3">
                                                <a href="javascript:acceptBat({$item.uid|default=0});" class="btn nopadding">通过审核</a>
                                                <else />
                                                <a href="javascript:cancelCheck({$item.uid|default=0});" class="btn nopadding">撤销审核</a>
                                                </neq>
                                                <a href="javascript:sendMsg({$item.uid},'{$item.nickname|default=''}');" class="btn nopadding">发消息</a>
                                                <a href="{:U('/Prom/Index/mail@'. getDomain(), array('nickname'=>$item['nickname'],'email'=>$item['email']))}" class="btn nopadding">发邮件</a>
                                                <a href="{:U('/Prom/Index/recom@'. getDomain(), array('oid'=>$item['uid'],'stype'=>2))}" class="btn nopadding">推荐到首页</a>
                                            </td>
                                        </tr>
                                    </volist>
                                    <tr>
                                        <td colspan="8">总计：{$total}&nbsp;用户，其中个人用户&nbsp;{$tcount}，企业用户&nbsp;{$ecount}</td>
                                    </tr>
                                    </tbody>
                                </table>
                            </div>
                        </div>					
                    </div>
                    <p>{$page}</p>
                </div>
            </div>
        </block>
<block name="b_footer_script">
    <div style="display: none;">
        <div id="sendbox" class="popbox-bg">
            <div class="title">发送消息</div>
            <div class="body">
                <p>内容</p>
                <textarea id="msg" placeholder="在这里输入消息内容……"></textarea>
                <p><a id='send' class="btn">发送</a><a id="cancel" class="btn pull-right">关闭</a></p>
            </div>
        </div>
    </div>
    <script>
        Date.prototype.Fmt = function(fmt)   
            { //author: meizz   
              var o = {   
                "M+" : this.getMonth()+1,                 //月份   
                "d+" : this.getDate(),                    //日   
                "h+" : this.getHours(),                   //小时   
                "m+" : this.getMinutes(),                 //分   
                "s+" : this.getSeconds(),                 //秒   
                "q+" : Math.floor((this.getMonth()+3)/3), //季度   
                "S"  : this.getMilliseconds()             //毫秒   
              };   
              if(/(y+)/.test(fmt))   
                fmt=fmt.replace(RegExp.$1, (this.getFullYear()+"").substr(4 - RegExp.$1.length));   
              for(var k in o)   
                if(new RegExp("("+ k +")").test(fmt))   
              fmt = fmt.replace(RegExp.$1, (RegExp.$1.length==1) ? (o[k]) : (("00"+ o[k]).substr((""+ o[k]).length)));   
              return fmt;   
            };
        
        $(document).ready(function(){
            var utbegin = $('#begin').val();
            var utend = $('#end').val();
            var dbegin = new Date();
            dbegin.setTime(utbegin*1000);
            var dend = new Date(utend);
            dend.setTime(utend*1000);
            $('#begins').val(dbegin.Fmt("yyyy-MM-dd hh:mm:ss"));
            $('#ends').val(dend.Fmt("yyyy-MM-dd hh:mm:ss"));
            
            $('#begins').on('blur',function(){
                $('#begin').val(Date.parse($(this).val())/1000);
            });
            $('#ends').on('blur',function(){
                $('#end').val(Date.parse($(this).val())/1000);
            });
        });
        
        function acceptBat(uid){
            var url = "{:U('/Prom/Index/acceptCheck_ajax@'. getDomain())}";
            $.post(url, {'uid':uid}, function(data){
                var vdata = eval(data);
                if(vdata.success==1){
                    alert('审核成功！');
                    window.location.reload();
                }else{
                    alert(vdata.msg);
                }
            }, 'json');
        }
        
        function cancelCheck(uid){
            var url = "{:U('/Prom/Index/cancelCheck_ajax@'. getDomain())}";
            $.post(url, {'uid':uid}, function(data){
                var vdata = eval(data);
                if(vdata.success==1){
                    alert('已经撤销对该用户的审核！');
                    window.location.reload();
                }else{
                    alert(vdata.msg);
                }
            }, 'json');
        }
        
        function sendMsg(recevier,nickname) {
            $('#sendbox .title').text('向 ['+nickname+'] 发送消息');
            $('#sendbox #send').unbind('click');
            $('#sendbox #send').click(function(){
                var url = "{:U('/Prom/Index/sendmsg_ajax@'. getDomain())}";
                var text = $('#sendbox #msg').val();
                if(text==''){
                    alert('未填写消息');
                    return fasle;
                }
                $.post(url, {'receiver':recevier, 'text':text}, function(data){
                    var vdata = eval(data);
                    if(vdata.success==1){
                        alert('消息发送成功！');
                    }else{
                        alert(vdata.msg);
                    }
                }, 'json');
            });
            $('#sendbox #cancel').unbind('click');
            $('#sendbox #cancel').click(function(){
                $.fancybox.close();
            });
            $.fancybox.open("#sendbox", { closeBtn: false, 'scrolling':'no', padding:0});
            return false;
        }
        function checkWord(){
            var kw = $('#searchword').val();
            if(kw==''){
                return false;
            }
            return true;
        }
    </script>
</block>